// =================================================================
// File: Superblock.h
// Desc: Contains the Superblock class
// =================================================================

#ifndef SUPERBLOCK_H
#define SUPERBLOCK_H

// =================================================================
// INCLUDES
// =================================================================

#include <vector>
#include <iostream>
#include <cstdlib>
using namespace std;

// =================================================================
// CLASSES
// =================================================================

// =================================================================
// Name: Superblock
// Desc: Stores essential information to structure of filesystem
// =================================================================
class Superblock
{

    public:
        Superblock();
        Superblock(int fs_size, int block_size,	int max_inodes);
        ~Superblock();

        // Add Get/Set for vectors
        void AddFreeInode(int index) {
            free_inodes.push_back(index);
        }
        void AddFreeDataBlock(int index) {
            free_blocks.push_back(index);
        }
        void SetBlockSize(int block_size) {
            this->block_size = block_size;
        }
        void SetFreeBlocks(const vector<int>& free_blocks) {
            this->free_blocks = free_blocks;
        }
        void SetFreeInodes(const vector<int>& free_inodes) {
            this->free_inodes = free_inodes;
        }
        void SetFsSize(int fs_size) {
            this->fs_size = fs_size;
        }
        int GetBlocksOffset() const {
            return blocks_offset;
        }
        int GetBlockSize() const {
            return block_size;
        }
        int GetNumDataBlocks() const {
            return num_data_blocks;
        }
        int GetFsSize() const {
            return fs_size;
        }
        int GetInodesOffset() const {
            return inodes_offset;
        }
        int GetNumInodes() const {
            return num_inodes;
        }
        int GetNumFreeInodes() const {
            return free_inodes.size();
        }
        int GetNumFreeDataBlocks() const {
            return free_blocks.size();
        }
        int GetFreeInodeIndex(int index) const {
            return free_inodes[index];
        }
        int GetFreeDataBlockIndex(int index) const {
            return free_blocks[index];
        }
        int FreeInodePop();
        int FreeDataBlockPop();


    private:
        int fs_size;		// size in bytes
        int block_size;		// bytes
        int num_inodes;		// number of inodes
        int num_data_blocks;	// total number of data blocks
        int inodes_offset;	// inode start location in bytes
        int blocks_offset; // block start location in bytes
        vector<int> free_inodes;
        vector<int> free_blocks;
        //Size of vectors

};

#endif // SUPERBLOCK_H
